package cn.bs.seckill.validator;



import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;

@Target({ElementType.METHOD,
        ElementType.FIELD,
        ElementType.ANNOTATION_TYPE,
        ElementType.CONSTRUCTOR,
        ElementType.PARAMETER,
        ElementType.TYPE_USE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
//校验规则
@Constraint(
        validatedBy = {MobileValidator.class}
)
/**
 * @Constraint( validatedBy = {MobileValidator.class})
 * 这个方法里面的参数,是校验规则,所以我们需要新建一个类来负责编写校验规则
 */
public @interface IsMobile {

    //添加一个方法作为验证手机号为必填
    boolean required() default true;

    String message() default "{请输入正确的手机号}";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};
}